#include <system.h>
#include <std.h>
#include <pio.h>
#include <memory.h>
#include <text.h>
#include <keyboard.h>
#include <sched.h>

/*pkey--> Function primary key
*/
#define PUTC 		1
#define PUTS        2
#define GETK	 	3
#define GETPID		4
#define END			5
#define REGISTER	0xff


unsigned long __sysfn(unsigned long pkey,unsigned long param2,unsigned long param3,unsigned long param4)
{
	unsigned long ret_val=0;
	switch(pkey)
	{
		case PUTC:ret_val=putchar_text((int)(param2));
		break;
		case PUTS:ret_val=printk((char *)(param2));
		break;
		case GETK:ret_val=get_key();
		break;
		case GETPID:ret_val=running_thread_id();
		break;
		case END:sti();
		delete_thread(param2);
		break;
	}
	param3=0;
	param4=0;
	return ret_val;
}

